var dataurl;
var data;
var bardiv;
var tablediv;
var callback;

function gotopage(currentpage, pagesize, totalrows,totalpage) {
	if (isNaN(currentpage)) {
		alert("\u9875\u53f7\u5fc5\u987b\u662f\u6570\u5b57\uff01");
		return false;
	}
		
	if(currentpage<1)
	{
	alert("输入的页号必须大于0!");
	return false;
	}
	
	if(currentpage>totalpage)
	{
	alert("输入的页号大于最大页数!");
	return false;
	}
	
	var url = dataurl + "?currentPage=" + currentpage;
	$.post(url, data, function (response) {
		document.getElementById(tablediv).innerHTML = response;
		if (callback != null) {
			callback();
		}
		var url1 = "page/queryCommonPage.action";
		$.post(url1, {"pageSize":pagesize, "currentPage":currentpage, "totalRows":totalrows}, function (response) {
			document.getElementById(bardiv).innerHTML = response;
		});
	});
}

function querypage(obj) {
	var url = obj.dataurl;
	dataurl = obj.dataurl;
	data = obj.data;
	bardiv = obj.bar;
	tablediv = obj.result;
	callback = obj.callback;
	$.post(obj.dataurl, obj.data, function (response) {
		document.getElementById(obj.result).innerHTML = response;
		var tempurl = obj.pageurl;
		$.post(tempurl, obj.data, function (response) {
			document.getElementById(obj.bar).innerHTML = response;
			if (obj.callback != null) {
				obj.callback();
			}
		});
	});
}
function querypage_total(obj) {
	var url = obj.dataurl;
	dataurl = obj.dataurl;
	data = obj.data;
	bardiv = obj.bar;
	tablediv = obj.result;
	callback = obj.callback;
	$.post(obj.dataurl, obj.data, function (response) {
		document.getElementById(obj.result).innerHTML = response;
		var tempurl = obj.pageurl + "?totalRows=" + document.getElementById("totalRows").value;
		$.post(tempurl, obj.data, function (response) {
			document.getElementById(obj.bar).innerHTML = response;
			if (obj.callback != null) {
				obj.callback();
			}
		});
	});
}


function doPageKeyDown(eventTag,currentpage, pagesize, totalrows,totalpage)
{
var event = eventTag||window.event;
	if (event.keyCode==13)
	{
	  gotopage(currentpage, pagesize, totalrows,totalpage);
	}
}


function querypageFirstStatic(obj, staticHtml) {
	var url = obj.dataurl;
	dataurl = obj.dataurl;
	data = obj.data;
	bardiv = obj.bar;
	tablediv = obj.result;
	callback = obj.callback;
	$.post(staticHtml, {}, function (response) {
		document.getElementById(obj.result).innerHTML = response;
		var tempurl = obj.pageurl;
		$.post(tempurl, obj.data, function (response) {
			document.getElementById(obj.bar).innerHTML = response;
			if (obj.callback != null) {
				obj.callback();
			}
		});
	});
}


function FormMenu(targ,selObj,restore){
     //eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
     eval("window.location='"+selObj.options[selObj.selectedIndex].value+"'");
     if(restore) selObj.selectedIndex=0;
}
